import React from 'react';
import ReactDOM from 'react-dom';
// import Greeting from './common/Greeting';
import 'bootstrap/dist/css/bootstrap.min.css'
import '../style/login.css';

class Login extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            show: true,
            name: props.name || '',
            data: ''
        };
        document.title = '首页';
    }

    componentDidMount() {
        // this.updateData();
    }

    // 更新数据
    updateData() {
        let that = this;
        let { data } = this.state;
        $.ajax({
            type: 'GET',
            url: 'http://localhost:3000/user',
            dataType: 'json',
            timeout: 300,
            success: function (data) {
                console.log('data: ', data);
                that.setState({
                    data: JSON.stringify(data)
                });
            },
            error: function (xhr, type) {
                console.log(xhr);
                console.log(type);
            }
        });
    }

    render() {
        let name = this.state.name || this.props.name || 'ha...';
        let { show, data } = this.state;
        console.log('jquery test: ', $.isArray([]));

        return <div>
            <p className="lead">bootstrap: {data}</p>
            <table className="text-center table table-bordered table-hover">
                <thead>
                    <tr className="info">
                        <th>顺序</th>
                        <th>名称</th>
                        <th>代码</th>
                        <th>日期</th>
                        <th>距今(天)</th>
                        <th>买价</th>
                        <th>最高价</th>
                        <th>最低价</th>
                        <th>今开</th>
                        <th>今收</th>
                        <th>今高</th>
                        <th>今低</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td className="active">1</td>
                        <td className="success">2</td>
                        <td className="warning">3</td>
                        <td className="danger">4</td>
                        <td className="info">5</td>
                        <td>6</td>
                        <td>7</td>
                        <td>8</td>
                        <td>9</td>
                        <td>10</td>
                        <td>11</td>
                        <td>12</td>
                    </tr>
                    <tr>
                        <td>2</td>
                    </tr>
                    <tr>
                        <td>3</td>
                    </tr>
                    <tr>
                        <td>4</td>
                    </tr>
                </tbody>
            </table>
        </div>;
    }
}

ReactDOM.render(
    <Login />,
    document.getElementById('app')
);